<template>
  <div class="box-alert"
       @click="hide">
    <span>{{message + " "}} </span>
  </div>
</template>
<script>
import $ from 'jquery'
export default {
  data () {
    return {
      message: "操作成功",
      flag: true
    }
  },
  watch: {
    visiable (val) {
      if (val)
        this.show();
      else
        this.hide();
    }
  },
  methods: {
    show () {
      let boxDom = $(".box-alert");
      boxDom.animate({ top: 0 }, 709).delay(800).animate({ top: -69 });
      if (this.flag) {
        boxDom.css("background", "#79ff79");
        boxDom.find("i").removeClass().addClass("iconfont icon-success");
      }
      else {
        boxDom.css("background", "#ff7575");
        boxDom.find("i").removeClass().addClass("iconfont icon-error");
      }
    },
    hide () {
      $(".box-alert").stop(true, true).animate({ top: -69 }, 600);
    }
  }
}
</script>
<style lang="less" scoped>
.box-alert {
  height: 69px;
  text-align: center;
  color: white;
  position: fixed;
  font-size: 16px;
  top: -69px;
  left: 0px;
  width: 100%;
  z-index: 9999;
  line-height: 60px;
  background: #f44336;
}
</style>